package com.nk.system.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nk.system.beans.ProgramBean;
import com.nk.system.common.search.Search;
import com.nk.system.dao.ProgramDao;
import com.nk.system.domain.Program;
import com.nk.system.service.ProgramService;

@Service("programService")
public class ProgramServiceImpl extends GenericServiceImpl<Program, String, ProgramDao>  implements ProgramService{

	private Logger log = Logger.getLogger(AuthenticationServiceImpl.class);
	
	@Autowired
	public ProgramServiceImpl(ProgramDao programDao) {
		super(programDao);
	}
	
	@Override
	public ProgramBean getProgram(ProgramBean majorID) {
		// TODO Auto-generated method stub
		ProgramBean programBean = null;
		
		try {
			Search search = new Search(Program.class);
			search.addFilterEqual("id", majorID.getId());
			
			Program programList = dao.searchUnique(search);
		
				programBean = new ProgramBean();
				programBean.setId(programList.getId());
				programBean.setZone(programList.getZone());
				programBean.setCountry(programList.getCountry());
				programBean.setUname(programList.getUname());
				programBean.setFaculty(programList.getFaculty());
				programBean.setMajor(programList.getMajor());
				programBean.setChargesB(programList.getChargesB());
				programBean.setChargesM(programList.getChargesM());
				programBean.setChargesD(programList.getChargesD());
				programBean.setAddress(programList.getAddress());
				programBean.setTel(programList.getTel());
				programBean.setWeb(programList.getWeb());
			
		}catch(Exception e) {
			log.error(e,e);
		}
		
		return programBean;
	}

	
	
}
